Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ResponseOps][Alerts] Move the alerts table to a dedicated package #207878

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

umbopepato
Copy link
Member

@umbopepato umbopepato commented Jan 22, 2025

Summary

This PR turns the AlertsTable into a standalone component, making it independent from the TriggersActionsUI plugin.

Removes the alerts table registry

All configuration is now managed through the AlertsTable component props. Shared configurations are handled by giving consumers the ability to directly provide alerts table wrapper components (see for example the renderAlertsTable prop of getCases).

Moves the alerts table to dedicated package(s)

Following the feature-driven structure we're introducing for ResponseOps (alerting) client-side packages:

  • @kbn/response-ops-alerts-table
  • @kbn/response-ops-alerts-apis
  • @kbn/response-ops-alerts-fields-browser

Initial work on improving composition and organization

  • Reorganizes the table code into a by-entity-type folder structure (components/, hooks/, ...)
  • Simplifies some components and breaks into smaller units when possible

To verify

For consumers of the alerts table:

  • Check that all your tables have the same behavior as before (columns, sort, row actions, bulk actions, etc.)
  • Check that your "shared" tables (i.e. cases alerts view in O11y and Security) have the expected configuration and behavior

Warning

This PR moves a lot of files. Git might not always recognize the correct delete/add file pairs. If you see weird diffs feel free to reach out for help!

Checklist

Identify risks

Risk Description Severity Mitigation
Table misconfigurations Some table configurations might slightly differ from the previous AlertsTableRegistry-backed version Low Quick fix

References

Closes #195180

@umbopepato umbopepato force-pushed the alerts-table-refactor branch from 99c6d4d to 72b83e5 Compare January 22, 2025 17:44
@umbopepato umbopepato added release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) labels Jan 23, 2025
@umbopepato umbopepato force-pushed the alerts-table-refactor branch from 72b83e5 to 002f502 Compare January 23, 2025 09:47
@umbopepato umbopepato marked this pull request as ready for review January 23, 2025 10:18
@umbopepato umbopepato requested review from a team as code owners January 23, 2025 10:18
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@umbopepato umbopepato requested review from a team as code owners January 23, 2025 10:18
@darnautov darnautov self-requested a review January 23, 2025 12:08
@jennypavlova jennypavlova self-requested a review January 23, 2025 14:01
Copy link
Member

@jennypavlova jennypavlova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ObsUx Infra and Services changes LGTM

Copy link
Member

@cnasikas cnasikas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ResponseOps team collectively approves.

Copy link
Contributor

@nikitaindik nikitaindik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reviewed the Rule Management table owned code and tested the changes on the Rule Details page. I approved on behalf of the Rule Management.

Copy link
Contributor

@js-jankisalvi js-jankisalvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested alerts table in security, o11y and stack management and cases alerts tab. works as expected 👍

@umbopepato umbopepato force-pushed the alerts-table-refactor branch from 5016bcc to 254d5fa Compare February 4, 2025 15:49
@cnasikas cnasikas added the v9.1.0 label Feb 5, 2025
Copy link
Contributor

@logeekal logeekal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @umbopepato for this refactor.

I have requested some very small changes regarding virtualization. Additionally, could I please ask you to create an issue to remove the workaround we added in this PR : #208052

@@ -21,7 +21,7 @@ export type CellValueElementProps = EuiDataGridCellValueElementProps & {
browserFields?: BrowserFields;
data: TimelineNonEcsData[];
ecsData?: Ecs;
eventId: string; // _id
eventId?: string; // _id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@umbopepato , Could you please elaborate in what case eventId will be undefined?

initialPageSize={50}
runtimeMappings={sourcererDataView?.runtimeFieldMap as RunTimeMappings}
toolbarVisibility={toolbarVisibility}
dynamicRowHeight={isEventRenderedView}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This statement disables the virtualization in Event Rendered View. We fixed this here: https://github.com/elastic/kibana/pull/192827/files#diff-55d89a9f7cd09ba80ef7752e07f2f65922b66e417052cb583f18f741f47608e4L293

This results in degraded performance

  • when user switches from Grid View to Event Rendered View as shown below.
  • Any subsequent re-renders

This Branch

Screen.Recording.2025-02-05.at.12.33.06.mov

Main ( 9.0 )

Screen.Recording.2025-02-05.at.12.34.28.mov

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this! I must have missed it while rebasing the feature branch

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem.. It is a big effort and huge list of changes. Can happen. Thanks for taking care of this.

}
cellActionsOptions={cellActionsOptions}
showInspectButton
services={{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please memoize all the non-primitive objects before passing to the components. This will otherwise result in unneeded renders because each time new instance of that object will be created.

Even if the object is memoized lower in the tree, it would not help since the identity of the object will anyways change at this component.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

tabType={'query'}
tableId={tableType}
width={0}
setEventsLoading={({ isLoading }) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should move this to a useCallback, setEventsDeleted as well, or as a reference outside of the render

} = useSelector((state: State) => eventsViewerSelector(state, tableType));
const eventContext = useContext(StatefulEventContext);

const timelineItem: TimelineItem = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should memoize this as it's creating a new object

const casesConfiguration = { featureId: CASES_FEATURE_ID, owner: [APP_ID], syncAlerts: true };
const emptyInputFilters: Filter[] = [];

export const AlertsTableComponent: FC<Omit<DetectionEngineAlertTableProps, 'services'>> = ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should wrap this in a memo

umbopepato and others added 13 commits February 6, 2025 12:39
- Removes the alerts table registry in favor of a props-only
configuration
- Converts all the usages of the alerts table to use only props

- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Christos Nasikas <[email protected]>
Moves the alerts table code and dependencies to dedicated packages in
`packages/response-ops/**`.

> [!IMPORTANT]
> 🚧 Merging to the `alerts-table-refactor` feature branch`

- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Christos Nasikas <[email protected]>
…tCases (#207038)

## Summary

> [!IMPORTANT]
> 🚧 Merging to the `alerts-table-refactor` feature branch, no review
needed from teams other than `response-ops`

> [!WARNING]
> Some tests are intentionally left failing since the converted usages
of the alerts table still have to be validated/improved by solutions and
may change significantly

Adds a `renderAlertsTable` prop to `getCases` to allow solutions to
customize the alerts table shown in the `Alerts` tab of their case view.
## Summary

The Security Solution alerts table CellValue component was receiving
some wrong props when used in the Rule preview table. This PR removes
the spread `{...props}` expression and type cast that didn't catch this
error and correctly converts props and types.
…om security flyout (#208052)

## Summary

Fixes the toggleColumn functionality not working from the Security
Solution flyout. Uses a global context to share a reference to the
`toggleColumn` function as a **temporary solution** until the handling
of the columns inside the alerts table is refactored to correctly
receive updates from the outside.
@umbopepato umbopepato force-pushed the alerts-table-refactor branch from 254d5fa to b11c7b9 Compare February 6, 2025 12:17
@elasticmachine
Copy link
Contributor

elasticmachine commented Feb 7, 2025

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #73 / Cases - group 1 View case Tabs - alerts linked to case should render the alerts table when opening the alerts tab
  • [job] [logs] FTR Configs #73 / Cases - group 1 View case Tabs - alerts linked to case should render the alerts table when opening the alerts tab
  • [job] [logs] Jest Tests #16 / Mappings editor: scaled float datatype should require a scaling factor to be provided
  • [job] [logs] Jest Tests #20 / SolutionFilter when the owner is a single solution should call onChange with selected solution id when no option selected yet

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
alerting 230 229 -1
cases 842 1032 +190
ml 2217 2441 +224
observability 1355 1450 +95
securitySolution 6695 6778 +83
slo 1001 1000 -1
threatIntelligence 139 177 +38
triggersActionsUi 944 927 -17
total +611

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/alerting-types 241 248 +7
@kbn/alerts-ui-shared 287 282 -5
@kbn/response-ops-alerts-fields-browser - 6 +6
@kbn/response-ops-alerts-table - 6 +6
observability 690 699 +9
ruleRegistry 222 221 -1
triggersActionsUi 570 543 -27
total -5

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
apm 4.0MB 4.0MB -452.0B
cases 540.8KB 1.3MB ⚠️ +805.2KB
cloudSecurityPosture 537.5KB 537.5KB +15.0B
discover 846.7KB 846.7KB +15.0B
infra 1.2MB 1.2MB -335.0B
ml 4.7MB 5.5MB ⚠️ +798.9KB
observability 1.3MB 1.4MB +88.7KB
securitySolution 21.4MB 18.8MB -2.6MB
slo 882.4KB 882.5KB +168.0B
synthetics 918.9KB 918.7KB -226.0B
threatIntelligence 57.6KB 758.0KB ⚠️ +700.3KB
triggersActionsUi 1.7MB 1.6MB -38.5KB
total -292.0KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/response-ops-alerts-apis - 1 +1
@kbn/response-ops-alerts-fields-browser - 2 +2
@kbn/response-ops-alerts-table - 13 +13
@kbn/securitysolution-data-table 6 10 +4
triggersActionsUi 51 40 -11
total +9

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
cases 162.5KB 163.9KB +1.4KB
esqlDataGrid 9.4KB 9.5KB +15.0B
ml 78.0KB 79.4KB +1.4KB
observability 102.4KB 102.5KB +108.0B
securitySolution 88.7KB 88.2KB -511.0B
threatIntelligence 12.7KB 12.8KB +102.0B
triggersActionsUi 130.2KB 118.8KB -11.4KB
total -8.9KB
Unknown metric groups

API count

id before after diff
@kbn/alerting-types 244 252 +8
@kbn/alerts-ui-shared 303 298 -5
@kbn/response-ops-alerts-fields-browser - 15 +15
@kbn/response-ops-alerts-table - 8 +8
observability 698 707 +9
triggersActionsUi 596 561 -35
total -0

async chunk count

id before after diff
cases 32 34 +2
ml 110 111 +1
observability 21 24 +3
securitySolution 109 110 +1
triggersActionsUi 65 58 -7
total -0

ESLint disabled in files

id before after diff
@kbn/response-ops-alerts-apis - 1 +1
@kbn/response-ops-alerts-table - 2 +2
total +3

ESLint disabled line counts

id before after diff
@kbn/response-ops-alerts-fields-browser - 1 +1
@kbn/response-ops-alerts-table - 8 +8
cases 64 65 +1
observability 42 46 +4
triggersActionsUi 130 120 -10
total +4

miscellaneous assets size

id before after diff
cases 0.0B 126.3KB +126.3KB
ml 211.1KB 337.5KB +126.3KB
total +252.6KB

References to deprecated APIs

id before after diff
@kbn/response-ops-alerts-table - 15 +15
triggersActionsUi 27 10 -17
total -2

Total ESLint disabled count

id before after diff
@kbn/response-ops-alerts-apis - 1 +1
@kbn/response-ops-alerts-fields-browser - 1 +1
@kbn/response-ops-alerts-table - 10 +10
cases 82 83 +1
observability 43 47 +4
triggersActionsUi 135 125 -10
total +7

History

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v9.0.0 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ResponseOps][Alerts] Move the alerts table into a dedicated package